package com.elvin.zoe.util;

import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

public class Configurator {
    private static Logger logger = Logger.getLogger(Configurator.class);

	private static final Properties properties = new Properties();

	public static String logWorkingFoler = null;
	public static String logArchiveFoler = null;
	public static String monthlyTemplateFile = null;
	public static String monthlyOutputFolder = null;
	public static String zoePhoneNumbers = null;

    private static void loadProperties(File propertyFile) {
        if (!propertyFile.exists()){
            logger.info(propertyFile.getAbsolutePath() + " not found.");
            return;
        }

        try {
            logger.info("loading property file - "+propertyFile.getAbsolutePath());
            properties.load(new FileInputStream(propertyFile));
        } catch (Exception e) {
            e.printStackTrace();
        }

        properties.list(System.out);
    }

	public static void init() {
	    loadProperties(new File("./zoe.properties"));
        loadProperties(new File("./src/main/resources/zoe.dev.properties"));

		logWorkingFoler = properties.getProperty("conversation.log.working.foler", "./ConversationLogs/working");
		logArchiveFoler = properties.getProperty("conversation.log.archive.foler", "./ConversationLogs/archive");
		monthlyTemplateFile = properties.getProperty("monthly.template.file", "./src/main/resources/templates/monthly.html");
		monthlyOutputFolder = properties.getProperty("monthly.output.folder", "./site/monthly");
		zoePhoneNumbers = properties.getProperty("zoe.phone.numbers");
	}

}
